<template>
  <el-container id="systemContainer">
    <el-header
      >销售员系统 【{{ nowUser }}】
      <el-button type="text" @click="open">退出</el-button>
    </el-header>
    <el-container>
      <el-aside width="200px">
        <SideBar />
      </el-aside>
      <el-main>
        <div></div>
        <router-view></router-view>
      </el-main>
    </el-container>
    <el-footer>Footer</el-footer>
  </el-container>
</template>
<script>
import SideBar from '../../components/common/SideBar'
import { createNamespacedHelpers } from 'vuex'
const { mapActions, mapState } = createNamespacedHelpers('login')
export default {
  data() {
    return {
      nowUser: '',
    }
  },
  mounted() {
    this.getUserInfo()
  },
  components: {
    SideBar,
  },
  methods: {
    ...mapActions(['getUserInfo', 'quit']),
    open() {
      this.$confirm('确认退出吗', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
        .then(() => {
          this.quit()
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消退出',
          })
        })
    },
  },
  computed: {
    ...mapState(['currentUser']),
  },
  watch: {
    currentUser: {
      handler(newVal, objVal) {
        this.nowUser = this.currentUser.account
      },
      deep: true,
    },
  },
}
</script>

<style>
#systemContainer {
  min-height: 100vh;
}

.el-header,
.el-footer {
  background-color: #b3c0d1;
  color: #333;
  text-align: center;
  line-height: 60px;
}

.el-aside {
  background-color: #d3dce6;
  color: #333;
  text-align: center;
}

.el-main {
  background-color: #e9eef3;
  color: #333;
  text-align: center;
}
</style>
